
// DeviceCloudDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DeviceCloud.h"
#include "DeviceCloudDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CDeviceCloudDlg dialog
CDeviceCloudDlg::CDeviceCloudDlg(CWnd* pParent /*=NULL*/)
    : CDialogMainBase(CDeviceCloudDlg::IDD, IDB_DLGP_BG, pParent )
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

CDeviceCloudDlg::~CDeviceCloudDlg()
{
}

void CDeviceCloudDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogMainBase::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_BTN_CLOSE, m_btnClose);
	DDX_Control(pDX, IDC_BTN_ACCOUNT, m_btnAccount);
	DDX_Control(pDX, IDC_BTN_SETTING, m_btnSetting);
	DDX_Control(pDX, IDC_BTN_ABOUT, m_btnAbout);
}

bool CDeviceCloudDlg::OnInitMainControls()
{
	CRect windowRect;
	GetWindowRect(&windowRect);

	m_btnClose.SetBntPicsID(IDB_BTNC_HO, IDB_BTNC_DE, IDB_BTNC_PR, IDB_BTNC_DI);
	m_btnClose.SetFontFamily(_T("Arial"));
	m_btnClose.SetFontSize(9);

	m_btnAccount.SetBntPicsID(IDB_BTNT_HO, IDB_BTNT_DE, IDB_BTNT_PR, IDB_BTNT_DI);
	m_btnAccount.SetFontFamily(_T("Arial"));
	m_btnAccount.SetFontSize(9);

	m_btnSetting.SetBntPicsID(IDB_BTNT_HO, IDB_BTNT_DE, IDB_BTNT_PR, IDB_BTNT_DI);
	m_btnSetting.SetFontFamily(_T("Arial"));
	m_btnSetting.SetFontSize(9);

	m_btnAbout.SetBntPicsID(IDB_BTNT_HO, IDB_BTNT_DE, IDB_BTNT_PR, IDB_BTNT_DI);
	m_btnAbout.SetFontFamily(_T("Arial"));
	m_btnAbout.SetFontSize(9);

	return true;
}

BEGIN_MESSAGE_MAP(CDeviceCloudDlg, CDialogMainBase)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BTN_CLOSE, &CDeviceCloudDlg::OnBnClickedBtnClose)
	ON_BN_CLICKED(IDC_BTN_ACCOUNT, &CDeviceCloudDlg::OnBnClickedBtnAccount)
	ON_BN_CLICKED(IDC_BTN_SETTING, &CDeviceCloudDlg::OnBnClickedBtnSetting)
	ON_BN_CLICKED(IDC_BTN_ABOUT, &CDeviceCloudDlg::OnBnClickedBtnAbout)
END_MESSAGE_MAP()


// CDeviceCloudDlg message handlers
BOOL CDeviceCloudDlg::OnInitDialog()
{
	CDialogMainBase::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	//Init children dialog
	CRect rect;  GetClientRect(&rect);
	rect.top    += DLG_CHILD_BGAP_T;
	rect.left   += DLG_CHILD_BGAP_L;
	rect.right  -= DLG_CHILD_BGAP_R;
	rect.bottom -= DLG_CHILD_BGAP_B;

	m_dlgAccount.Create(CDCAccountDlg::IDD, this);
	m_dlgAccount.MoveWindow(&rect);
	
	m_dlgSetting.Create(CDCSettingDlg::IDD, this);
	m_dlgSetting.MoveWindow(&rect);


	m_dlgAccount.ShowWindow(SW_HIDE);
	m_dlgSetting.ShowWindow(SW_SHOW);
	
	//m_dlgAccount.ShowWindow(SW_SHOW);
	//m_dlgSetting.ShowWindow(SW_HIDE);

	return TRUE;  // return TRUE  unless you set the focus to a control
}


// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDeviceCloudDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDeviceCloudDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CDeviceCloudDlg::OnBnClickedBtnClose()
{
	// TODO: Add your control notification handler code here
	OnCancel();
}

void CDeviceCloudDlg::OnBnClickedBtnAccount()
{
	// TODO: Add your control notification handler code here
	m_dlgAccount.ShowWindow(SW_SHOW);
	m_dlgSetting.ShowWindow(SW_HIDE);
}

void CDeviceCloudDlg::OnBnClickedBtnSetting()
{
	// TODO: Add your control notification handler code here
	m_dlgAccount.ShowWindow(SW_HIDE);
	m_dlgSetting.ShowWindow(SW_SHOW);
}

void CDeviceCloudDlg::OnBnClickedBtnAbout()
{
	// TODO: Add your control notification handler code here
}
